#include "Wave.h"
#include "EnemyManager.h"
#include "AI.h"

CWave::CWave(void): route(new CRoute()), numberOfEnemies(0)
{}

CWave::CWave(int enemyType, int numberOfEnemies):enemyType(enemyType),numberOfEnemies(numberOfEnemies)
{}

CWave::~CWave(void)
{
	delete route;
	route=0;
	this->numberOfEnemies=0;
}

/*create the enemies in the entity vector in the world model*/
void CWave::createEnemies(void)
{
	for(int i=0;i<numberOfEnemies;i++)
	{
		//the speed and the speed of shooting of the enemies depend on the difficulty.
		switch(AI.getDifficulty())
		{
			case eDifficultyEasy:
				ENEMYMANAGER.spawnEnemy(this->enemyType, this->timeToSpawn+3*i*this->timeBetweenEnemyToSpawn, this->timeToLive,
			this->route,3,1500);
				break;

			case eDifficultyNormal:
				ENEMYMANAGER.spawnEnemy(this->enemyType, this->timeToSpawn+2*i*this->timeBetweenEnemyToSpawn, this->timeToLive,
			this->route,5,1000);
				break;

			case eDifficultyHard:
				ENEMYMANAGER.spawnEnemy(this->enemyType, this->timeToSpawn+i*this->timeBetweenEnemyToSpawn, this->timeToLive,
			this->route,7,500);
				break;
		}
		
	}
}

/*create a waypoint*/
void CWave::createWayPoint(CVector2D v)
{
	this->route->addWaypoint(v);
}

int CWave::getNumberOfEnemies(void)const
{
	return this->numberOfEnemies;
}
int CWave::getEnemyType(void)const
{
	return this->enemyType;
}

int CWave::getNumberOfWayPoint(void)const
{
	return this->route->getNumberOfWayPoint();
}
int CWave::getTimeToSpawn(void) const
{
	return this->timeToSpawn;
}
int CWave::getTimeToLive(void)const
{
	return this->timeToLive;
}
int CWave::getTimeBetweenEnemyToSpawn(void) const
{
	return this->timeBetweenEnemyToSpawn;
}
void CWave::setNumberOfEnemies(int numberOfEnemies)
{
	this->numberOfEnemies=numberOfEnemies;
}
void CWave::setEnemyType(int enemyType)
{
	this->enemyType=enemyType;
}

void CWave::setTimeToSpawn(int timeToSpawn)
{
	this->timeToSpawn=timeToSpawn;
}
void CWave::setTimeBetweenEnemyToSpawn(int timeBetweenEnemyToSpawn)
{
	this->timeBetweenEnemyToSpawn=timeBetweenEnemyToSpawn;
}
void CWave::setTimeToLive(int timeToLive)
{
	this->timeToLive=timeToLive;
}